Skip to content

[feature](routineload) Add routine load target-table alter support#64878

Open
0AyanamiRei wants to merge 14 commits into
apache:masterfrom
0AyanamiRei:feature/routine-load-target-table-switch
Open

[feature](routineload) Add routine load target-table alter support#64878
0AyanamiRei wants to merge 14 commits into
apache:masterfrom
0AyanamiRei:feature/routine-load-target-table-switch

Conversation

@0AyanamiRei

@0AyanamiRei 0AyanamiRei commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: N/A

Related PR: N/A

Problem Summary:

Routine Load target-table alteration was initially limited to the target-only syntax ALTER ROUTINE LOAD FOR [db.]job ON table. It could not alter supported job or data-source properties in the same statement.

This PR replaces that syntax with the explicit, composable form:

ALTER ROUTINE LOAD FOR [<db>.]<job_name>
SET TARGET TABLE = "<table_name>"
[<job_properties>]
FROM [<data_source>]
[<data_source_properties>]

The implementation has the following behavior and constraints:

  • SET TARGET TABLE can be combined with supported job properties and Kafka/Kinesis data-source properties.
  • Target switching remains mutually exclusive with load clauses such as COLUMNS, WHERE, and PARTITION.
  • The job must be paused and single-table. The target must be a non-temporary OLAP table in the job database, pass LOAD privilege checks, and be compatible with the existing load description, distribution mode, and partial-update settings.
  • An explicit FROM type must match the existing job type; Kafka and Kinesis jobs cannot be converted into each other.
  • Existing Doris mutable-property allowlists are preserved. Unknown/create-only properties are rejected, including Kafka multi-table routing properties during ALTER. Doris retains its existing support for altering kafka_topic, unlike StarRocks.
  • Target-table, job-property, and data-source changes are applied and persisted together. Kafka source changes are staged or prevalidated to avoid partial in-memory mutation, and replay does not perform offset lookups or Cloud MetaService RPCs.
  • Kafka/Kinesis default offsets or positions are changed only when explicitly supplied. Altering a broker, stream, or custom property no longer synthesizes and overwrites an unspecified default position.
  • Routine Load progress is preserved for target-only/custom-property changes; topic or stream changes retain the existing Doris progress-reset behavior.

Release note

ALTER ROUTINE LOAD now uses SET TARGET TABLE = "table" to switch the target table and supports combining the switch with supported PROPERTIES and FROM data-source properties in one statement.

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes. The target-table syntax changes from ON table to SET TARGET TABLE = "table", and supported job/source properties can now be altered in the same statement.
  • Does this need documentation?

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

### What problem does this PR solve?

Issue Number: None
Related PR: None
Problem Summary: Allow paused single-table Routine Load jobs to switch their target table with ALTER ROUTINE LOAD FOR [db.]job ON <table>, while preserving existing progress and replaying the new table binding from edit log.

### Release note

Support ALTER ROUTINE LOAD ... ON <table> to switch the target table for paused single-table routine load jobs.

### Check List (For Author)

- Test: FE unit test
  - "/data/data3/huangruixin/include/src-master/apache-maven-3.9.9/bin/mvn -pl fe-core -am -DskipITs -Dcheckstyle.skip=true -DfailIfNoTests=false -Dtest=org.apache.doris.nereids.trees.plans.commands.AlterRoutineLoadCommandTest,org.apache.doris.persist.AlterRoutineLoadOperationLogTest,org.apache.doris.load.routineload.KafkaRoutineLoadJobTest test"
  - Kinesis unit tests skipped per user request
- Behavior changed: Yes (new ALTER ROUTINE LOAD target-table switch behavior)
- Does this need documentation: Yes (documented in /data/data3/huangruixin/docs/routine-load-alter-table-design.html)
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@0AyanamiRei 0AyanamiRei marked this pull request as draft June 26, 2026 06:04
### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: Follow-up review found two issues in the new routine load target-table alter support. First, `AlterRoutineLoadCommand` had an import order regression that could fail FE checkstyle. Second, alter validation only rechecked `PARTIAL_COLUMNS=true` from the current command, which left the effective partial-update state under-validated when the existing job or a `unique_key_update_mode` change required merge-on-write semantics. This change restores import ordering, validates the effective unique key update mode against the destination table, and adds focused FE unit coverage for those cases.

### Release note

Routine Load alter now rejects target-table or unique-key-update changes that are incompatible with partial update requirements.

### Check List (For Author)

- Test: Unit Test
- Behavior changed: Yes
- Does this need documentation: No
@0AyanamiRei 0AyanamiRei marked this pull request as ready for review June 29, 2026 01:11
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: The routine load target-table alter change hit FE checkstyle in CI because one validation error message exceeded the line-length limit and a unit-test import order did not match the FE custom import ordering rule. This commit makes the minimal formatting-only fixes so the branch aligns with FE style checks.

### Release note

None

### Check List (For Author)

- Test: No need to test (formatting-only fix requested by reviewer; no local build or test run)
- Behavior changed: No
- Does this need documentation: No
@0AyanamiRei 0AyanamiRei changed the title [feature](fe) Add routine load target-table alter support [feature](routineload) Add routine load target-table alter support Jun 29, 2026
@sollhui

sollhui commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

/review

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: The routine load target-table alter implementation had a single-use helper for constructing the validation load descriptor snapshot, and the parser branch for table-only alter did not mark the intended phase-one scope. This commit inlines the one-off snapshot construction at the validation call site and documents that the current parser branch only supports target table alteration before future support for combining target-table and property changes.

### Release note

None

### Check List (For Author)

- Test: No need to test (review follow-up only; no local build or test run)
- Behavior changed: No
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed for PR 64878 at head 760890d.

I found one correctness issue: validation can accept an alter that later leaves the routine-load job in partial-update mode on a non-MoW table.

Critical checkpoints:

  • Goal: the PR adds single-table routine-load target-table alteration while preserving stream progress; the implementation largely wires parser, command validation, job mutation, replay, display, and tests, but the partial-update validation path is inconsistent with mutation for one property combination.
  • Scope/focus: the target-table change is small and localized to routine-load command/job/persistence paths.
  • Concurrency/lifecycle: mutation is still gated by the existing paused-job write lock; no new background thread or lock order was introduced.
  • Configuration/session propagation: no new config item; existing routine-load session/job properties are reused.
  • Compatibility/persistence: new log field is backward-readable by current code; target-table id is replayed in Kafka and Kinesis paths.
  • Parallel paths: Kafka and Kinesis both update/replay targetTableId; scheduling/task planning uses the current job tableId.
  • Tests: parser/command/persistence/unit coverage and a Kafka regression were added. I verified git diff --check and mvn -pl fe-core -DskipTests checkstyle:check. I did not run FE compile/unit/regression tests because this checkout lacks thirdparty/installed/bin/protoc and thirdparty/installed.
  • User focus: no additional user-provided focus was present.

Subagent conclusions: optimizer-rewrite proposed OPT-001, which became inline comment MAIN-001. tests-session-config reported no distinct candidate. Convergence round 1 ended with both live subagents replying NO_NEW_VALUABLE_FINDINGS for the same current ledger/comment set.

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Codex completed, but no new pull request review was submitted for the current head SHA.
Workflow run: https://github.com/apache/doris/actions/runs/28345324644

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 50.63% (40/79) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29129 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 760890d5d7eef15765b1fc92f16783d7301870c2, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17723	4017	4145	4017
q2	2022	319	187	187
q3	10328	1532	851	851
q4	4699	468	341	341
q5	7700	845	582	582
q6	204	173	141	141
q7	776	848	628	628
q8	10199	1487	1606	1487
q9	5907	4480	4460	4460
q10	6772	1809	1503	1503
q11	440	286	248	248
q12	629	430	310	310
q13	18087	3385	2817	2817
q14	265	256	244	244
q15	q16	782	773	706	706
q17	1029	955	1029	955
q18	6797	5786	5453	5453
q19	1173	1277	1096	1096
q20	509	411	263	263
q21	5699	2559	2539	2539
q22	446	356	301	301
Total cold run time: 102186 ms
Total hot run time: 29129 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4418	4256	4290	4256
q2	320	366	227	227
q3	4539	4941	4364	4364
q4	2083	2151	1366	1366
q5	4451	4327	4297	4297
q6	233	181	134	134
q7	1740	1936	1826	1826
q8	2423	2181	2100	2100
q9	8114	8044	8082	8044
q10	4852	4758	4301	4301
q11	565	425	389	389
q12	735	762	646	646
q13	3317	3589	2994	2994
q14	300	305	278	278
q15	q16	758	761	679	679
q17	1350	1344	1328	1328
q18	7947	7410	6831	6831
q19	1137	1104	1129	1104
q20	2274	2215	1948	1948
q21	5268	4573	4537	4537
q22	511	465	402	402
Total cold run time: 57335 ms
Total hot run time: 52051 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 171607 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 760890d5d7eef15765b1fc92f16783d7301870c2, data reload: false

query5	4322	626	484	484
query6	430	183	171	171
query7	4810	553	302	302
query8	334	180	163	163
query9	8757	4085	4079	4079
query10	424	316	261	261
query11	5806	2352	2123	2123
query12	156	102	99	99
query13	1278	579	413	413
query14	6270	5269	4957	4957
query14_1	4327	4295	4289	4289
query15	219	202	179	179
query16	1038	447	432	432
query17	1107	711	604	604
query18	2432	465	337	337
query19	197	181	145	145
query20	113	108	103	103
query21	214	144	116	116
query22	13798	13672	13407	13407
query23	17262	16399	16148	16148
query23_1	16279	16175	16292	16175
query24	7465	1786	1326	1326
query24_1	1337	1283	1325	1283
query25	579	455	388	388
query26	1318	326	174	174
query27	2678	583	345	345
query28	4474	2032	2037	2032
query29	1099	651	520	520
query30	309	235	208	208
query31	1126	1091	946	946
query32	106	64	60	60
query33	547	320	262	262
query34	1167	1109	654	654
query35	775	796	686	686
query36	1414	1390	1241	1241
query37	154	115	92	92
query38	1902	1723	1671	1671
query39	926	936	915	915
query39_1	873	882	896	882
query40	231	126	106	106
query41	69	68	68	68
query42	91	90	88	88
query43	324	322	277	277
query44	1473	817	782	782
query45	216	194	181	181
query46	1075	1199	760	760
query47	2345	2351	2264	2264
query48	404	411	323	323
query49	595	438	326	326
query50	1069	370	267	267
query51	4406	4417	4350	4350
query52	82	83	73	73
query53	244	274	199	199
query54	277	234	211	211
query55	77	73	68	68
query56	261	233	236	233
query57	1428	1435	1302	1302
query58	245	217	223	217
query59	1558	1650	1439	1439
query60	284	256	239	239
query61	182	177	213	177
query62	704	644	573	573
query63	237	193	190	190
query64	2525	773	625	625
query65	4820	4804	4771	4771
query66	1818	460	330	330
query67	28846	28759	28682	28682
query68	3220	1539	931	931
query69	418	308	261	261
query70	1082	1022	991	991
query71	311	238	213	213
query72	2915	2867	2340	2340
query73	890	800	439	439
query74	5133	4990	4751	4751
query75	2601	2541	2180	2180
query76	2308	1201	783	783
query77	392	379	293	293
query78	12392	12431	11997	11997
query79	1407	1137	762	762
query80	1236	454	387	387
query81	514	280	250	250
query82	612	156	117	117
query83	317	276	247	247
query84	264	139	115	115
query85	885	510	438	438
query86	439	325	276	276
query87	1841	1827	1776	1776
query88	3756	2810	2779	2779
query89	426	378	334	334
query90	1870	186	187	186
query91	174	160	137	137
query92	65	62	53	53
query93	1600	1474	874	874
query94	715	352	333	333
query95	669	469	347	347
query96	1139	806	348	348
query97	2683	2660	2554	2554
query98	217	206	201	201
query99	1161	1163	1067	1067
Total cold run time: 257841 ms
Total hot run time: 171607 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.95 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 760890d5d7eef15765b1fc92f16783d7301870c2, data reload: false

query1	0.01	0.01	0.00
query2	0.10	0.04	0.05
query3	0.25	0.16	0.13
query4	1.60	0.14	0.14
query5	0.24	0.22	0.22
query6	1.26	1.05	1.02
query7	0.03	0.01	0.01
query8	0.06	0.04	0.04
query9	0.39	0.32	0.34
query10	0.58	0.54	0.58
query11	0.18	0.15	0.15
query12	0.18	0.15	0.14
query13	0.48	0.47	0.47
query14	1.02	1.01	0.98
query15	0.61	0.59	0.58
query16	0.33	0.31	0.30
query17	1.08	1.12	1.04
query18	0.22	0.21	0.22
query19	2.05	1.90	1.90
query20	0.01	0.01	0.01
query21	15.44	0.19	0.14
query22	4.95	0.06	0.05
query23	16.13	0.31	0.12
query24	2.98	0.41	0.31
query25	0.11	0.06	0.04
query26	0.74	0.23	0.15
query27	0.05	0.03	0.03
query28	3.53	0.90	0.52
query29	12.50	4.33	3.45
query30	0.28	0.15	0.16
query31	2.77	0.60	0.31
query32	3.22	0.60	0.50
query33	3.17	3.16	3.31
query34	15.51	4.21	3.50
query35	3.48	3.51	3.54
query36	0.54	0.42	0.43
query37	0.10	0.07	0.06
query38	0.05	0.04	0.03
query39	0.04	0.03	0.03
query40	0.17	0.16	0.15
query41	0.08	0.03	0.03
query42	0.03	0.02	0.02
query43	0.04	0.04	0.03
Total cold run time: 96.59 s
Total hot run time: 24.95 s

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: ALTER ROUTINE LOAD validation handled unique_key_update_mode and legacy partial_columns with different precedence from the mutation path. An ALTER containing unique_key_update_mode=UPSERT and partial_columns=true could pass validation on a non-MoW table, then be applied as UPDATE_FIXED_COLUMNS. Flexible partial-update ALTERs on non-MoW tables were also rejected by the generic PARTIAL_COLUMNS validation before reaching the flexible partial-update validation path. This change makes generic partial-column validation apply only to fixed partial update mode and makes the mutation path ignore legacy partial_columns when an explicit unique_key_update_mode is present. The routine load alter regression test also declares its polling counters as local variables to satisfy regression framework script checks.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.nereids.trees.plans.commands.AlterRoutineLoadCommandTest,org.apache.doris.load.routineload.KafkaRoutineLoadJobTest,org.apache.doris.load.routineload.KinesisRoutineLoadJobTest
- Behavior changed: No
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29371 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 0f1be9e1aa029625b1f257ceac9fe5f6776bc2fc, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17598	3988	3987	3987
q2	1993	317	192	192
q3	10335	1398	828	828
q4	4683	473	338	338
q5	7513	852	566	566
q6	181	171	139	139
q7	759	844	615	615
q8	9344	1658	1669	1658
q9	5580	4582	4473	4473
q10	6792	1763	1533	1533
q11	456	276	241	241
q12	625	424	287	287
q13	18093	3420	2758	2758
q14	266	260	242	242
q15	q16	792	779	710	710
q17	895	933	941	933
q18	7074	5747	5616	5616
q19	1163	1250	1090	1090
q20	493	389	260	260
q21	6217	2842	2584	2584
q22	478	370	321	321
Total cold run time: 101330 ms
Total hot run time: 29371 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5136	4712	4760	4712
q2	345	365	240	240
q3	4880	5272	4774	4774
q4	2087	2139	1399	1399
q5	4785	4840	4640	4640
q6	235	181	124	124
q7	1874	1756	1665	1665
q8	2440	2132	2084	2084
q9	8099	7818	7536	7536
q10	4736	4671	4199	4199
q11	543	384	351	351
q12	729	741	525	525
q13	2956	3407	2786	2786
q14	278	296	250	250
q15	q16	669	706	630	630
q17	1285	1252	1245	1245
q18	7506	6819	6743	6743
q19	1107	1076	1117	1076
q20	2241	2222	1977	1977
q21	5290	4628	4439	4439
q22	515	460	408	408
Total cold run time: 57736 ms
Total hot run time: 51803 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 172483 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 0f1be9e1aa029625b1f257ceac9fe5f6776bc2fc, data reload: false

query5	4302	609	495	495
query6	438	195	168	168
query7	4818	560	293	293
query8	328	178	162	162
query9	8794	4033	4025	4025
query10	458	317	264	264
query11	5931	2352	2147	2147
query12	156	100	100	100
query13	1267	607	449	449
query14	6236	5290	4937	4937
query14_1	4245	4260	4247	4247
query15	206	198	179	179
query16	993	460	435	435
query17	919	710	565	565
query18	2424	478	347	347
query19	197	181	140	140
query20	111	108	105	105
query21	219	135	113	113
query22	13587	13582	13354	13354
query23	17315	16513	16224	16224
query23_1	16185	16346	16222	16222
query24	7514	1784	1294	1294
query24_1	1344	1299	1319	1299
query25	571	474	397	397
query26	1299	314	175	175
query27	2716	574	322	322
query28	4474	2055	2055	2055
query29	1101	630	527	527
query30	323	241	206	206
query31	1122	1081	975	975
query32	109	65	62	62
query33	563	328	260	260
query34	1182	1106	678	678
query35	805	793	684	684
query36	1426	1457	1246	1246
query37	158	107	94	94
query38	1892	1729	1621	1621
query39	921	913	887	887
query39_1	866	885	871	871
query40	228	123	105	105
query41	70	70	69	69
query42	91	87	95	87
query43	319	323	282	282
query44	1422	797	801	797
query45	202	196	182	182
query46	1078	1236	743	743
query47	2407	2373	2273	2273
query48	386	428	295	295
query49	583	431	325	325
query50	1022	350	276	276
query51	4420	4488	4402	4402
query52	82	82	72	72
query53	256	257	195	195
query54	272	232	211	211
query55	79	72	68	68
query56	260	239	230	230
query57	1432	1419	1314	1314
query58	259	235	224	224
query59	1564	1606	1471	1471
query60	293	264	248	248
query61	168	170	199	170
query62	685	646	592	592
query63	232	181	195	181
query64	2513	747	608	608
query65	4879	4747	4773	4747
query66	1829	457	337	337
query67	29759	29672	29501	29501
query68	3100	1625	882	882
query69	414	296	272	272
query70	1052	952	939	939
query71	303	230	211	211
query72	2928	2669	2391	2391
query73	828	775	429	429
query74	5145	4935	4760	4760
query75	2568	2553	2166	2166
query76	2330	1207	765	765
query77	338	375	274	274
query78	12400	12667	11892	11892
query79	1396	1213	779	779
query80	769	465	389	389
query81	486	285	245	245
query82	573	158	120	120
query83	331	278	248	248
query84	328	144	113	113
query85	904	534	425	425
query86	400	314	281	281
query87	1832	1832	1741	1741
query88	3686	2819	2799	2799
query89	428	393	337	337
query90	1784	179	175	175
query91	170	171	166	166
query92	64	57	55	55
query93	1569	1449	916	916
query94	608	303	313	303
query95	691	470	350	350
query96	1103	816	351	351
query97	2683	2690	2548	2548
query98	216	207	200	200
query99	1209	1171	1024	1024
Total cold run time: 257278 ms
Total hot run time: 172483 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25.33 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 0f1be9e1aa029625b1f257ceac9fe5f6776bc2fc, data reload: false

query1	0.01	0.01	0.01
query2	0.09	0.05	0.05
query3	0.26	0.14	0.14
query4	1.61	0.14	0.13
query5	0.23	0.25	0.22
query6	1.23	1.07	1.07
query7	0.04	0.01	0.01
query8	0.06	0.04	0.04
query9	0.38	0.31	0.30
query10	0.58	0.55	0.54
query11	0.19	0.14	0.14
query12	0.18	0.15	0.15
query13	0.47	0.47	0.48
query14	1.02	1.02	1.01
query15	0.61	0.59	0.58
query16	0.31	0.32	0.31
query17	1.09	1.14	1.13
query18	0.22	0.20	0.20
query19	2.08	1.97	1.94
query20	0.01	0.02	0.01
query21	15.44	0.20	0.13
query22	4.80	0.05	0.05
query23	16.13	0.30	0.12
query24	3.02	0.43	0.33
query25	0.10	0.04	0.05
query26	0.73	0.20	0.17
query27	0.03	0.04	0.03
query28	3.51	0.94	0.53
query29	12.50	4.30	3.45
query30	0.27	0.15	0.16
query31	2.77	0.58	0.31
query32	3.22	0.60	0.50
query33	3.13	3.24	3.26
query34	15.58	4.21	3.53
query35	3.55	3.52	3.54
query36	0.57	0.44	0.42
query37	0.09	0.07	0.06
query38	0.05	0.04	0.03
query39	0.03	0.04	0.03
query40	0.18	0.17	0.15
query41	0.08	0.03	0.02
query42	0.03	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 96.52 s
Total hot run time: 25.33 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 51.22% (42/82) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 57.32% (47/82) 🎉
Increment coverage report
Complete coverage report

@0AyanamiRei 0AyanamiRei changed the title [feature](routineload) Add routine load target-table alter support [feature](routineload) phase1 : Add routine load target-table alter support Jun 30, 2026
@sollhui

sollhui commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed for PR 64878 at head 0f1be9e.

I did not find any new substantiated issue to raise. The previously reported partial-update precedence issue is already covered by the existing inline thread and appears fixed in the current head: explicit unique_key_update_mode now removes partial_columns from the apply map, and validation only enforces the MoW check for effective UPDATE_FIXED_COLUMNS.

Critical checkpoints:

  • Goal: the PR adds single-table routine-load target-table alteration while preserving stream progress. Current parser, command validation, job mutation, journal replay, show paths, and tests are aligned with that goal.
  • Scope/focus: the implementation is localized to routine-load command/job/persistence paths plus targeted parser, unit, and regression coverage.
  • Concurrency/lifecycle: live mutation remains gated by the existing paused-job write lock; queued stale tasks are filtered by checkTaskInJob after pause clears the task list; no new thread or lock order was introduced.
  • Configuration/session propagation: no new config item was added; existing routine-load properties and Nereids task-info propagation are reused.
  • Compatibility/persistence: targetTableId is Gson-annotated in AlterRoutineLoadJobOperationLog, current-code replay handles missing legacy targetTableId as 0, and both Kafka and Kinesis replay paths apply the new target table id without resetting progress.
  • Parallel paths: Kafka and Kinesis live/replay paths both update targetTableId; task planning and transaction begin use the current job tableId.
  • Tests: parser/command/persistence/unit coverage and an external-Kafka regression cover the target-table switch and the fixed partial-update precedence behavior. I did not run FE build/unit/regression tests because this checkout lacks thirdparty/installed and thirdparty/installed/bin/protoc. I checked added diff lines for trailing whitespace; none were introduced by this PR.
  • User focus: no additional user-provided review focus was present.

Subagent conclusions: optimizer-rewrite reported NO_NEW_VALUABLE_FINDINGS in its focused pass and again in convergence round 1. tests-session-config also reported NO_NEW_VALUABLE_FINDINGS in its focused pass and convergence round 1. No subagent candidates became inline comments, and the final proposed inline comment set is empty.

sollhui
sollhui previously approved these changes Jun 30, 2026

@sollhui sollhui left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Jun 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: ALTER ROUTINE LOAD previously used the ON target-table syntax and could not combine a target switch with supported job or data-source properties. Add the explicit SET TARGET TABLE syntax, preserve Doris property constraints, validate and apply target/job/source changes atomically, and keep unspecified Kafka and Kinesis default positions unchanged.

### Release note

ALTER ROUTINE LOAD now uses SET TARGET TABLE = "table" and can combine a target table switch with supported PROPERTIES and FROM data-source properties.

### Check List (For Author)

- Test: Regression test / Unit Test / Build
    - FE routine-load and parser unit tests
    - load_p0/routine_load/test_routine_load_alter regression test
    - ./build.sh --fe -j48
- Behavior changed: Yes. ALTER ROUTINE LOAD target-table syntax and composability changed as described above.
- Does this need documentation: Yes (tracked by Related PR apache#64878)
@github-actions github-actions Bot removed the approved Indicates a PR has been approved by one committer. label Jul 15, 2026
@0AyanamiRei 0AyanamiRei changed the title [feature](routineload) phase1 : Add routine load target-table alter support [feature](routineload) Add routine load target-table alter support Jul 15, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#64878

Problem Summary: Routine load target-table alteration validated the target outside the mutation critical section, Kafka datetime default offsets could leak Doris-only properties to librdkafka, and SHOW could combine an old target table name with newly altered job state. Centralize ALTER mutation under the job and target metadata locks, repeat complete target validation before mutation, filter both internal Kafka default-offset properties, and read SHOW state under the job read lock.

### Release note

Fix routine load target-table alteration consistency and Kafka datetime default-offset handling.

### Check List (For Author)

- Test: Unit Test
    - `./run-fe-ut.sh --run org.apache.doris.load.routineload.KafkaRoutineLoadJobTest,org.apache.doris.load.routineload.KinesisRoutineLoadJobTest,org.apache.doris.load.routineload.RoutineLoadJobTest`
    - `./build.sh --fe -j48`
- Behavior changed: Yes, target-table ALTER is validated atomically, Doris-only Kafka properties are filtered, and SHOW uses a consistent job snapshot
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#64878

Problem Summary: ALTER ROUTINE LOAD target-table switching is supported only for Kafka jobs. Remove the redundant Kinesis implementation and tests, restore the existing Kinesis ALTER behavior, and reject target-table changes for non-Kafka jobs during command validation.

### Release note

ALTER ROUTINE LOAD SET TARGET TABLE supports Kafka Routine Load jobs only.

### Check List (For Author)

- Test: Not run (per request)
- Behavior changed: Yes. Kinesis jobs now explicitly reject target-table changes.
- Does this need documentation: Yes. Document the Kafka-only limitation.
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#64878

Problem Summary: Restricting target-table alteration to Kafka restored the old Kinesis modifyProperties override, but RoutineLoadJob now requires subclasses to implement unprotectModifyProperties. This caused FE compilation to fail. Implement the required Kinesis hook by delegating to the existing property mutation path while keeping target-table alteration rejected for non-Kafka jobs.

### Release note

None

### Check List (For Author)

- Test:
    - Unit Test: Routine Load focused FE UT (71 tests)
    - FE build: ./build.sh --fe --clean -j48
- Behavior changed: No. Kinesis target-table alteration remains unsupported.
- Does this need documentation: No
@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 68.91% (184/267) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29514 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit bd1fad56ceaa3908902d68ad44a61c4329cb0c5c, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17791	4057	4030	4030
q2	2089	323	207	207
q3	10229	1424	833	833
q4	4679	470	344	344
q5	7501	844	565	565
q6	181	170	136	136
q7	763	811	612	612
q8	9331	1614	1492	1492
q9	5551	4310	4305	4305
q10	6815	1728	1480	1480
q11	506	376	324	324
q12	727	582	442	442
q13	18092	3401	2785	2785
q14	269	264	242	242
q15	q16	796	781	715	715
q17	1049	967	956	956
q18	7088	5889	5651	5651
q19	1311	1269	1083	1083
q20	796	649	566	566
q21	5902	2664	2447	2447
q22	448	352	299	299
Total cold run time: 101914 ms
Total hot run time: 29514 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4380	4271	4257	4257
q2	290	316	212	212
q3	4537	4967	4428	4428
q4	2055	2151	1374	1374
q5	4407	4275	4237	4237
q6	229	171	125	125
q7	1746	1856	1961	1856
q8	2519	2135	2174	2135
q9	7895	8101	7709	7709
q10	4727	4626	4158	4158
q11	552	409	378	378
q12	767	756	546	546
q13	3248	3614	3003	3003
q14	336	304	292	292
q15	q16	720	740	629	629
q17	1341	1329	1355	1329
q18	8115	7231	7235	7231
q19	1169	1132	1058	1058
q20	2192	2212	1925	1925
q21	5213	4548	4406	4406
q22	518	467	417	417
Total cold run time: 56956 ms
Total hot run time: 51705 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 177882 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit bd1fad56ceaa3908902d68ad44a61c4329cb0c5c, data reload: false

query5	4305	621	480	480
query6	468	224	205	205
query7	4873	619	321	321
query8	358	187	174	174
query9	8783	4023	4005	4005
query10	452	378	307	307
query11	5888	2317	2132	2132
query12	172	100	99	99
query13	1269	585	421	421
query14	6231	5232	4911	4911
query14_1	4252	4266	4223	4223
query15	202	200	174	174
query16	1003	479	435	435
query17	917	688	568	568
query18	2418	442	339	339
query19	209	180	149	149
query20	107	107	105	105
query21	232	158	142	142
query22	13573	13582	13312	13312
query23	17308	16585	16103	16103
query23_1	16202	16272	16330	16272
query24	7567	1754	1271	1271
query24_1	1271	1323	1295	1295
query25	581	474	393	393
query26	1329	390	216	216
query27	2562	599	400	400
query28	4528	1977	1975	1975
query29	1100	624	504	504
query30	346	264	243	243
query31	1105	1083	977	977
query32	125	60	58	58
query33	498	315	247	247
query34	1163	1108	651	651
query35	764	793	658	658
query36	1185	1182	1066	1066
query37	150	111	89	89
query38	1880	1698	1641	1641
query39	886	878	841	841
query39_1	835	819	846	819
query40	260	160	139	139
query41	64	61	63	61
query42	92	88	89	88
query43	316	323	278	278
query44	1422	775	753	753
query45	196	184	172	172
query46	1069	1210	752	752
query47	2177	2099	1998	1998
query48	396	394	275	275
query49	575	417	324	324
query50	1034	408	338	338
query51	10630	10737	10659	10659
query52	88	95	75	75
query53	262	284	204	204
query54	274	241	215	215
query55	74	82	65	65
query56	278	309	301	301
query57	1334	1320	1207	1207
query58	287	252	249	249
query59	1570	1608	1407	1407
query60	306	280	261	261
query61	158	158	151	151
query62	539	488	426	426
query63	241	199	203	199
query64	2840	1031	832	832
query65	4730	4618	4634	4618
query66	1839	508	384	384
query67	29349	29111	29014	29014
query68	2898	1523	1007	1007
query69	406	295	269	269
query70	1053	984	951	951
query71	361	354	329	329
query72	3006	2658	2413	2413
query73	805	816	430	430
query74	5066	4886	4722	4722
query75	2530	2509	2125	2125
query76	2337	1177	776	776
query77	344	356	280	280
query78	11777	11713	11361	11361
query79	1202	1086	759	759
query80	606	537	467	467
query81	472	329	284	284
query82	235	158	118	118
query83	314	350	290	290
query84	307	164	131	131
query85	903	608	516	516
query86	325	279	277	277
query87	1816	1832	1771	1771
query88	3654	2789	2751	2751
query89	411	372	334	334
query90	2125	193	197	193
query91	201	186	155	155
query92	64	57	57	57
query93	1506	1504	1032	1032
query94	538	367	349	349
query95	809	575	495	495
query96	1046	842	335	335
query97	2654	2609	2472	2472
query98	212	210	201	201
query99	1086	1113	967	967
Total cold run time: 260623 ms
Total hot run time: 177882 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25.18 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit bd1fad56ceaa3908902d68ad44a61c4329cb0c5c, data reload: false

query1	0.01	0.01	0.00
query2	0.10	0.05	0.05
query3	0.27	0.14	0.14
query4	1.60	0.14	0.14
query5	0.26	0.22	0.21
query6	1.23	1.06	1.07
query7	0.04	0.01	0.00
query8	0.06	0.04	0.04
query9	0.37	0.31	0.33
query10	0.54	0.59	0.58
query11	0.19	0.14	0.13
query12	0.18	0.14	0.15
query13	0.48	0.49	0.48
query14	1.02	1.01	0.99
query15	0.62	0.60	0.60
query16	0.30	0.34	0.33
query17	1.09	1.13	1.11
query18	0.23	0.23	0.23
query19	2.11	1.92	1.96
query20	0.02	0.01	0.02
query21	15.45	0.23	0.15
query22	4.87	0.05	0.05
query23	16.11	0.31	0.12
query24	2.98	0.41	0.29
query25	0.12	0.04	0.05
query26	0.75	0.22	0.17
query27	0.04	0.02	0.03
query28	3.39	0.95	0.57
query29	12.48	4.14	3.32
query30	0.27	0.17	0.18
query31	2.78	0.60	0.30
query32	3.22	0.59	0.50
query33	3.22	3.18	3.21
query34	15.58	4.22	3.55
query35	3.52	3.50	3.55
query36	0.54	0.44	0.42
query37	0.09	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.02
query40	0.18	0.16	0.15
query41	0.09	0.02	0.03
query42	0.04	0.04	0.04
query43	0.04	0.03	0.04
Total cold run time: 96.57 s
Total hot run time: 25.18 s

@sollhui

sollhui commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

/review

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Codex completed, but no new pull request review was submitted for the current head SHA.
Workflow run: https://github.com/apache/doris/actions/runs/29490118916

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@0AyanamiRei

Copy link
Copy Markdown
Contributor Author

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants